import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import "./plugins/element.js";
import "./assets/css/global.css";
import axios from "axios";
// 导入全局样式表
import "./assets/font/iconfont.css";
// 引用树形表
import TreeTable from "vue-table-with-tree-grid";
import store from "./store";
import './filter/dataformat'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
// 注册富文本编辑器
Vue.use(VueQuillEditor);
Vue.config.productionTip = false;

// 设置  请求的根路径
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/";
// 设置axios请求拦截器  为头部加上访问的token
axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem("token");
  return config;
});
// 设置axios响应拦截器  解构响应的数据
axios.interceptors.response.use(res => {
  const { data } = res;
  return data;
});
// 将axios挂在   vue的原型上  让所有组件都能访问到
// 能访问到的原因是    vc.__proto__.prototype=vm.__proto__  所以挂在后能访问
Vue.prototype.axios = axios;
// 全局注册树形表
Vue.component('tree-table', TreeTable);
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
